new Vue({
    el: '#classify',
    data: {
        classify: null,
        articles: null,
        classifyId: null,
        showIndex: 0,
        isFollowClassify: false
    },
    methods: {
    },
    created:function(){
        let that = this
        get("/getClassify", function(data){
            that.classify = data
            if (data != null) {
                that.classifyId = data[0].classifyId
                getArticlesByClassifyId(that, data[0].classifyId)
                // 替换专题公告
                replaceHtml("#description", that.classify[that.showIndex].description)
                // 左侧导航栏的切换以及数据请求
                $(function(){
                    let items = $("#classify .leftNav li")
                    items.each(function(index){
                        $(this).click(function(){
                            that.showIndex = index
                            getArticlesByClassifyId(that, data[index].classifyId)
                            replaceHtml("#description", that.classify[that.showIndex].description)
                            items.each(function(){
                                $(this).removeClass("active")
                            })
                            $(this).addClass("active")
                        })
                    })
                })
            } 
        })
    }
})


function getArticlesByClassifyId(that, classifyId){
    get("/getArticleList/" + classifyId, function(data){
        that.articles = data
    })
}
